<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
	xmlns:f="livcos.org/ns/xslt/function"
	exclude-result-prefixes="f">
	
	<xsl:import href="../../sys/resolver.xsl"/>
	
	<xsl:variable name="docPath" select="$basePath"/>
	
	<xsl:template match="uri" mode="#all">
		<xsl:call-template name="standard-access"/>
	</xsl:template>
	
	<xsl:template match="uri[@ext = 'html']">
		<access obj="{$docPath}/document" scope="view">
			<param key="ref" value="{@relativeName}"/>
		</access>
	</xsl:template>
	
	<xsl:template match="uri[@ext = 'pdf']">
		<access obj="{$docPath}/style/fo/pdf" scope="view">
  		<param key="ref" value="{@relativeName}"/>
    </access>
  </xsl:template>
  
	<!-- map special paths -->
	
	<xsl:template match="uri[contains(@full, '/image/')]" priority="2">
		<access obj="{f:find-data-object(@relativeName)}" scope="view"/>
	</xsl:template>
	
	<xsl:template match="uri[contains(@full, '/media/')]" priority="2">
		<access obj="{f:find-data-object(@relativeName)}" scope="view"/>
	</xsl:template>
	
	<xsl:template match="uri[starts-with(@relative, 'palette/')]" priority="2">
		<access scope="view" obj="/livcos.org/web/palette">
			<param key="ref" value="{f:find-data-object(substring-after(@relativeName, 'palette/'))}"/>
		</access>
	</xsl:template>
	
	<!-- special views -->
	
	<xsl:template match="uri[@relative = 'Intro.html']" priority="2">
		<access obj="/livcos.org/web/Intro" scope="view">
			<param key="ref" value="{@relativeName}"/>
		</access>
	</xsl:template>
	
	<xsl:template match="uri[@full = '/livcos.org/web/index.html']" priority="2">
		<access obj="{$basePath}/{@relativeName}" scope="view"/>
	</xsl:template>
  
  <xsl:template match="uri[@full = '/livcos.org/web/data.html']" priority="2">
  	<access obj="{$basePath}/{@relativeName}" scope="view"/>
  </xsl:template>
  
	<xsl:template match="uri[starts-with(@relative, 'admin/') and (@ext = 'html')]" priority="3">
		<access obj="{$basePath}/{@relativeName}" scope="view"/>
	</xsl:template>
	
	<xsl:template match="uri[starts-with(@relative, 'data/')]" priority="3">
		<access obj="/livcos.org/web/data" scope="view">
			<param key="ref" value="{substring(@relativeName, 6)}"/>
		</access>
	</xsl:template>
	
</xsl:stylesheet>